The present invention relates to an arrangement for executing program code, said arrangement comprises definition loading means for loading at least two definition entities into memory, said definition entities being associated with said definition loading means, the arrangement further comprises object creating means for creating objects according to said definition entity.
The present invention is also related to a method for executing program code and a tangible medium carrying a computer program for performing a method for executing program code.
An arrangement according to the preamble is known from the publication xe2x80x9cThe Java(trademark) Virtual Machine Specificationxe2x80x9d by Tim Lindholm and Frank Yellin, which is available from the Sun web site and is converted from the printed book, September 1996, first printing.
In recent years the popularity of the Java platform has increased substantially. Java is a platform which comprises the Java language which is compiled to a byte code which runs on a Java Virtual Machine.
The use of a byte code which runs on a virtual machine has the advantage that the compiled byte code can be executed on every combination of hardware and operating system if a virtual machine exist for such combination.
The Java language is object oriented, which means that during the execution of the programs objects are created according to a definition entity, which can be a class or an interface in the Java language. Before objects can be created, the needed definition entities (classes or interfaces) have to be loaded first in memory. This loading is done by the definition loading means, which are called class loaders in the Java language. There can exist different definition loading means for different ways of loading definition entities. In Java there can e.g. be different class loaders for loading classes from disk, from a TCP/IP based network or loading them from an MPEG-2 Transport stream.
The Java virtual machine has a memory management system which performs garbage collection to delete automatically objects and classes that are not needed anymore.
When Java is to be used in consumer appliances such as TV""s and set-top boxes, only limited amounts of memory resources are available. Currently the use of Java for consumer applications is quite difficult due to that limited amount of memory available.
The object of the present invention is to provide an arrangement according to the preamble in which the required amount of memory is decreased.
To achieve said objective, the arrangement according to the invention is characterized in that the arrangement comprises memory management means for removing from memory definition entities having no related objects, said definition loading means being associated with definition entities still having related objects.
By removing definition entities having no related objects anymore from memory, substantial amounts of memory can be freed, resulting in that the arrangement requires less memory than the arrangement according to the prior art.
The invention is based on the recognition that in the present specification of the Java virtual machine it is prescribed that a definition entity may only be deleted if its definition loading means is not reachable anymore. This means that no objects exist anymore of which the definition entity has been loaded by said definition loading means.
This will be made clearer in the following example. If a class loader (definition loading means) has loaded two classes (definition entities), a first loaded class having no related object anymore may not be removed from memory as long the other class still has related objects. The result of this is that classes remain unnecessary long in memory.
By using the inventive idea according to the present invention, classes may be unloaded as soon they are not needed anymore.
An embodiment of the present invention is characterized in that the arrangement comprises designation means for designating definition entities as removable, in that the memory management means are arranged for removing from memory definition entities having no related objects when the definition entity is designated as removable, and in that the memory management means are arranged for removing from memory definition entities corresponding to definition loading means being associated with only definition entities having no related objects.
There may be circumstances that it is undesirable that definition entities having no related objects are always removed from memory. This can be the case when class variables are modified by the execution of class methods. If such a class is removed from memory and is reloaded when it is needed again, the value of the class variable may be changed.
By only removing definition entities without related objects when they are designated as removable, the application program can control this removal by designating a definition entity as removable or not removable.
A further embodiment of the invention is characterized in that said arrangement comprises storing means for storing an identification of definition entities that are designated as removable.
An easy way of communicating to the memory management means whether a class can be unloaded if it has no related objects is to store a table in which all loaded classed are entered together with an indication whether this class is removable or not. Alternatively, it is possible to store the identification in an object header associated with each class object.